﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OneOfAll.Common.Models
{
    public class EquipmentModel : BaseModel
    {
        private string name = string.Empty;
        public string Name
        {
            get { return name; }
            set { name = value; RaisePropertyChanged(); }
        }

        private string introduce = string.Empty;
        public string Introduce
        {
            get { return introduce; }
            set { introduce = value; RaisePropertyChanged(); }
        }

        private ObservableCollection<string> experiences = new ObservableCollection<string>();
        public ObservableCollection<string> Experiences
        {
            get { return experiences; }
            set { experiences = value; RaisePropertyChanged(); }
        }

        private EquipmentTypeEnum type = EquipmentTypeEnum.帽子;
        public EquipmentTypeEnum Type
        {
            get { return type; }
            set { type = value; RaisePropertyChanged();}
        }

        private int lv = 1;
        public int Lv
        {
            get { return lv; }
            set { lv = value; RaisePropertyChanged(); }
        }

        private int etherealize = 0;
        public int Etherealize
        {
            get { return etherealize; }
            set { etherealize = value; EtherealizeChanged();  RaisePropertyChanged(); }
        }

        private int currentSoul = 0;
        public int CurrentSoul
        {
            get { return currentSoul; }
            set 
            { 
                currentSoul = value;
                while (CurrentSoul >= NeedSoul)
                {
                    CurrentSoul -= NeedSoul;
                    Etherealize++;
                }
                RaisePropertyChanged();
            }
        }

        private int needSoul = 1000;
        public int NeedSoul
        {
            get { return needSoul; }
            set { needSoul = value; RaisePropertyChanged(); }
        }

        private int base_Power = 0;
        public int Base_Power
        {
            get { return base_Power; }
            set { base_Power = value; RaisePropertyChanged(); }
        }

        private int base_Strong = 0;
        public int Base_Strong
        {
            get { return base_Strong; }
            set { base_Strong = value; RaisePropertyChanged(); }
        }

        private int base_Trick = 0;
        public int Base_Trick
        {
            get { return base_Trick; }
            set { base_Trick = value; RaisePropertyChanged(); }
        }

        private int base_Wit = 0;
        public int Base_Wit
        {
            get { return base_Wit; }
            set { base_Wit = value; RaisePropertyChanged(); }
        }

        private int base_Hp = 0;
        public int Base_Hp
        {
            get { return base_Hp; }
            set { base_Hp = value; RaisePropertyChanged(); }
        }

        private int base_Mp = 0;
        public int Base_Mp
        {
            get { return base_Mp; }
            set { base_Mp = value; RaisePropertyChanged(); }
        }

        private int base_Attack = 0;
        public int Base_Attack
        {
            get { return base_Attack; }
            set { base_Attack = value; RaisePropertyChanged(); }
        }

        private int base_Defense = 0;
        public int Base_Defense
        {
            get { return base_Defense; }
            set { base_Defense = value; RaisePropertyChanged(); }
        }

        private int base_Wakan = 0;
        public int Base_Wakan
        {
            get { return base_Wakan; }
            set { base_Wakan = value; RaisePropertyChanged(); }
        }

        private int base_Dodge = 0;
        public int Base_Dodge
        {
            get { return base_Dodge; }
            set { base_Dodge = value; RaisePropertyChanged(); }
        }

        private int base_Accurate = 0;
        public int Base_Accurate
        {
            get { return base_Accurate; }
            set { base_Accurate = value; RaisePropertyChanged(); }
        }

        private int base_CriticalChance = 0;
        public int Base_CriticalChance
        {
            get { return base_CriticalChance; }
            set { base_CriticalChance = value; RaisePropertyChanged(); }
        }

        private int base_CriticalValue = 0;
        public int Base_CriticalValue
        {
            get { return base_CriticalValue; }
            set { base_CriticalValue = value; RaisePropertyChanged(); }
        }

        private int power = 0;
        public int Power
        {
            get { return power; }
            set { power = value; RaisePropertyChanged(); }
        }

        private int strong = 0;
        public int Strong
        {
            get { return strong; }
            set { strong = value; RaisePropertyChanged(); }
        }

        private int trick = 0;
        public int Trick
        {
            get { return trick; }
            set { trick = value; RaisePropertyChanged(); }
        }

        private int wit = 0;
        public int Wit
        {
            get { return wit; }
            set { wit = value; RaisePropertyChanged(); }
        }

        private int hp = 0;
        public int Hp
        {
            get { return hp; }
            set { hp = value; RaisePropertyChanged(); }
        }

        private int mp = 0;
        public int Mp
        {
            get { return mp; }
            set { mp = value; RaisePropertyChanged(); }
        }

        private int attack = 0;
        public int Attack
        {
            get { return attack; }
            set { attack = value; RaisePropertyChanged(); }
        }

        private int defense = 0;
        public int Defense
        {
            get { return defense; }
            set { defense = value; RaisePropertyChanged(); }
        }

        private int dodge = 0;
        public int Dodge
        {
            get { return dodge; }
            set { dodge = value; RaisePropertyChanged(); }
        }

        private int accurate = 0;
        public int Accurate
        {
            get { return accurate; }
            set { accurate = value; RaisePropertyChanged(); }
        }

        private int criticalChance = 0;
        public int CriticalChance
        {
            get { return criticalChance; }
            set { criticalChance = value; RaisePropertyChanged(); }
        }

        private int criticalValue = 0;
        public int CriticalValue
        {
            get { return criticalValue; }
            set { criticalValue = value; RaisePropertyChanged(); }
        }


        private void EtherealizeChanged()
        {
            if (Etherealize <= 0) return;
            NeedSoul = (int)(1000 * Math.Sqrt(etherealize));
            Power = (int)(Math.Pow(1.1, Etherealize) * Base_Power);
            Strong = (int)(Math.Pow(1.1, Etherealize) * Base_Strong);
            Trick = (int)(Math.Pow(1.1, Etherealize) * Base_Trick);
            Wit = (int)(Math.Pow(1.1, Etherealize) * Base_Wit);
            Hp = (int)(Math.Pow(1.1, Etherealize) * Base_Hp);
            Mp = (int)(Math.Pow(1.1, Etherealize) * Base_Mp);
            Attack = (int)(Math.Pow(1.1, Etherealize) * Base_Attack);
            Defense = (int)(Math.Pow(1.1, Etherealize) * Base_Defense);
            Dodge = (int)(Math.Pow(1.1, Etherealize) * Base_Dodge);
            Accurate = (int)(Math.Pow(1.1, Etherealize) * Base_Accurate);
            CriticalChance = (int)(Math.Pow(1.1, Etherealize) * Base_CriticalChance);
            CriticalValue = (int)(Math.Pow(1.1, Etherealize) * Base_CriticalValue);
        }
    }
}
